package com.chixing.day09_innerclass.orderclass;

public class OrderProcessUtil {
    /*
    * 实现通用
    * */

    public static  Order[] process(Order order){ // 个人订单对象 Order order = new  PersonalOrder()
        int newLength=(int)Math.ceil((double) order.getProtectNum()/1000);
//        int newLength = (int) ( Math.ceil(order.getProdectNum()/1000) );
        System.out.println(newLength);
        Order[] orders= new Order[ newLength ];
        int count =0;
        // 2500 = 1000+1000+500
        while(order.getProdectNum()>1000){
            Order subOrder = order.clone();  //【通用】 (1)new 订单对象 (2) 属性 = 原始订单属性
            subOrder.setProdectNum(1000);
            order.setProdectNum(order.getProdectNum()-1000);
            orders[count++] = subOrder;
        }
        orders[count] = order;
        return orders;
    }
}
